﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LifeTree.DomainModel.Repositories;
using LifeTree.DomainModel.Entities;

namespace LifeTree.Mvc.Tests
{
    public class TaskRepositoryFake : ITaskRepository
    {
        private List<Task> tasks = new List<Task>();

        public List<Task> Tasks
        {
            get { return tasks; }
        }

        #region IRepository<Task> Members

        public void Add(Task entity)
        {
            tasks.Add(entity);
        }

        public void Remove(Task entity)
        {
            tasks.Remove(entity);
        }

        public Task GetById(string id)
        {
            return tasks.FirstOrDefault(t => t.Id == id);
        }

        public IEnumerable<Task> GetAll()
        {
            return tasks;
        }

        public Task GetActiveTask()
        {
            return tasks.FirstOrDefault(t => t.Status == TaskStatuses.Active);
        }

        #endregion
    }
}
